export const httpURL = 'https://jch.xiaobiaohui.com';
export const BASEURL = httpURL + '/index.php/index';
const json2url = (datas) => {
	if (!datas) {
		return ''
	}
	let arr = [];
	for (let key in datas) {
		arr.push(key + "=" + datas[key]);
	}
	return '?' + arr.join("&");
}
const http = ({
	url,
	method = 'get',
	data = {},
	params = {},
	header = {
		'content-type': 'application/json'
	}
}) => {
	if (!url) {
		return
	}
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASEURL + url + json2url(params),
			method,
			data,
			header,
			success(res) {
				// console.log(process.env)
				resolve(res);
			},
			fail(err) {
				reject(err)
			}
		})
	})
}
export default http
